/*
 Copyright (c) 2007-2008 The Regents of the University of California.
 All rights reserved.

 Permission is hereby granted, without written agreement and without
 license or royalty fees, to use, copy, modify, and distribute this
 software and its documentation for any purpose, provided that the
 above copyright notice and the following two paragraphs appear in all
 copies of this software and that appropriate acknowledgments are made
 to the research of the COSI group.

 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.

 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
 ENHANCEMENTS, OR MODIFICATIONS.

 Author : Alessandro Pinto <apinto@eecs.berkeley.edu>
 University of California, Berkeley
 545 Cory Hall, Berkeley, CA 94720
 */
#ifndef THREAD_H_
#define THREAD_H_

#include <iostream>
#include <string>
#include "core/Quantity.h"

namespace cosi {

/** This class represents a thread. A thread has a name, the name of the destination node,
 * the name of the destination thread,
 * the period of the messages that the thread generates and their length in bit.
 *
 *
 *@author Alessandro Pinto,
 *@author The Donald O. Pederson Center for Electronic System Design
 *@author Electrical Engineering Department
 *@author University of California, Berkeley
 *@author 545P Cory Hall, Berkeley, CA 94720
 *@author +1 (510) 642 9670
 *@author http://www.eecs.berkeley.edu/~apinto
 *
 *@version $Id: Thread.h,v 1.5 2008/12/09 23:28:25 apinto Exp $
 */

class Thread : public cosi::Quantity {
	/**\brief Thread name.*/
	std::string mThreadName;
	/**\brief Name of the destination node.*/
	std::string mDestinationNodeName;
	/**\brief Id of the destination node.*/
	int mDestId;
	/**\brief Destination thread name.*/
	std::string mDestinationThreadName;
	/**\brief Message period in seconds.*/
	double mPeriod;
	/**\brief Message length in bits.*/
	int mMsgLength;
public:
	/**\brief Default constructor.*/
	Thread();
	/**\brief Default destructor.*/
	~Thread();

	/**\brief Returns this thread.*/
	Thread Get();

	/**\brief Sets this thread*/
	void Set(Thread pT);

	/**\brief Sets the name of this thread.*/
	std::string GetThreadName() const;

	/**\brief Gets the name of this thread.*/
	void SetThreadName(std::string pName);

	/**\brief Sets the name of the destination thread.*/
	std::string GetDestinationThreadName() const ;

	/**\brief Gets the name of the destination thread.*/
	void SetDestinationThreadName(std::string pName);

	/**\brief Sets the name of the destination node.*/
	std::string GetDestinationNodeName() const ;

	/**\brief Gets the name of the destination node.*/
	void SetDestinationNodeName(std::string pName);

	/**\brief Sets the Id of the destination node.*/
	int GetDestinationNodeId() const;

	/**\brief Gets the id of the destination node.*/
	void SetDestinationNodeId(int pId);

	/**\brief Gets the message period generated by the thread.*/
	double GetPeriod() const;

	/**\brief Sets the message period generated by the thread.*/
	void SetPeriod(double pPeriod);

	/**\brief Gets the length of the messages.*/
	int GetMessageLength() const;

	/**\brief Sets the length of the messages.*/
	void SetMessageLength(int pMessageLength);

	Thread& operator=(const Thread& pT) ;

	bool operator<(const Thread &pT) const;

	bool operator==(const Thread &pT) const;

	friend std::ostream& operator<<(std::ostream &pOs , const Thread &pT) ;

};

}

#endif /*THREAD_H_*/
